package com.xn.app.muying.adpter;

import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.DoctorGsonBean;
import com.xn.app.muying.util.HttpUtil;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/11/1.
 */
public class DoctorRightAdapter extends BaseAdapter {
    private final LayoutInflater inflater;
    private Context context;
    private ArrayList<DoctorGsonBean.SubCompaniesBean> list = new ArrayList();
    private String data;
    private Handler handler = new Handler();

    public DoctorRightAdapter(Context context, Handler handler) {
        this.context = context;
        this.handler = handler;
        inflater = LayoutInflater.from(context);
    }

    public void getData(ArrayList<DoctorGsonBean.SubCompaniesBean> data) {
        this.list.clear();
        this.list.addAll(data);

        notifyDataSetChanged();
    }

    public ArrayList<DoctorGsonBean.SubCompaniesBean> getListData() {
        return this.list;
    }

    public DoctorRightAdapter getAdapter() {
        return this;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = inflater.inflate(R.layout.doctorrightlistview, null);
            holder = new ViewHolder();
            holder.tv = (TextView) view.findViewById(R.id.doctorright_tv);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.tv.setText(list.get(i).getName());

        return view;
    }

    class ViewHolder {
        TextView tv;
    }


}

